package com.csap.framework.oauth2;

import com.csap.framework.oauth2.cache.IdGetCache;
import com.csap.framework.oauth2.cache.StrategyType;
import com.csap.framework.oauth2.model.ResultResponse;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author ycf
 * @Date 2022/3/10 5:00 PM
 * @Version 1.0
 */
@Component
public class CacheGetImpl implements CacheGet {
    @Resource
    private IdGetCache<String> idGetCache;
    @Resource
    private IdCache idCache;

    @Override
    public ResultResponse getId(Long id, StrategyType... keys) {
        return get(id, keys);
    }

    @Override
    public ResultResponse getEleNum(String eleNum, StrategyType... keys) {
        return get(idGetCache.getNumId(eleNum, idCache::getNumId), keys);
    }

    @Override
    public ResultResponse getEleImei(String eleImpl, StrategyType... keys) {
        return get(idGetCache.getEleImel(eleImpl, idCache::getEleImel), keys);
    }

}
